/*
 *  Copyright 2013 yura.
 * 
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */

/*
 * ObjectEditPanel.java
 *
 * Created on 13.01.2013, 22:09:01
 */

package org.opu.db.obj.vis.ui.client.widgets;

import java.awt.event.ActionEvent;
import org.opu.db.obj.vis.domain.domains.ObjectEntry;
import org.opu.db.obj.vis.ui.actions.AbstractAction;
import org.opu.db.obj.vis.ui.client.i18n.AbstractI18N;

/**
 *
 * @author yura
 */
public class ObjectEditPanel extends javax.swing.JDialog {
    protected AbstractI18N panelIs18n = new AbstractI18N(AbstractEntityPanel.I18N);

    /** Creates new form ObjectEditPanel */
    public ObjectEditPanel(ObjectEntry entity) {
        setModal(true);
        initComponents();
        abstractEntityPanel.init(entity);
        okBtn.setAction(new AbstractAction(true) {

            @Override
            public String getName() {
                return "Ok";
            }

            @Override
            public void action(ActionEvent e) throws Exception {
                dispose();
                onActionFinish();
            }
        });
        cancelBtn.setAction(new AbstractAction(true) {

            @Override
            public String getName() {
                return "Cancel";
            }

            @Override
            public void action(ActionEvent e) throws Exception {
                dispose();
                onActionFinish();
            }
        });
        setLocationRelativeTo(null);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        contentPanel = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        cancelBtn = new javax.swing.JButton();
        okBtn = new javax.swing.JButton();
        attributePanel = new javax.swing.JPanel();
        abstractEntityPanel = new org.opu.db.obj.vis.ui.client.widgets.AbstractEntityPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle(panelIs18n.getString("objectEdit.title")); // NOI18N

        contentPanel.setLayout(new java.awt.BorderLayout(5, 5));

        jPanel1.setLayout(new java.awt.BorderLayout());

        jPanel2.setPreferredSize(new java.awt.Dimension(435, 40));

        cancelBtn.setText("cancel");

        okBtn.setText("ok");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(60, 60, 60)
                .addComponent(okBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(28, 28, 28)
                .addComponent(cancelBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(120, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(okBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cancelBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(13, 13, 13))
        );

        jPanel1.add(jPanel2, java.awt.BorderLayout.SOUTH);

        attributePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(panelIs18n.getString("attributes.title"))); // NOI18N

        javax.swing.GroupLayout attributePanelLayout = new javax.swing.GroupLayout(attributePanel);
        attributePanel.setLayout(attributePanelLayout);
        attributePanelLayout.setHorizontalGroup(
            attributePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 434, Short.MAX_VALUE)
        );
        attributePanelLayout.setVerticalGroup(
            attributePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        jPanel1.add(attributePanel, java.awt.BorderLayout.CENTER);

        contentPanel.add(jPanel1, java.awt.BorderLayout.SOUTH);

        javax.swing.GroupLayout abstractEntityPanelLayout = new javax.swing.GroupLayout(abstractEntityPanel);
        abstractEntityPanel.setLayout(abstractEntityPanelLayout);
        abstractEntityPanelLayout.setHorizontalGroup(
            abstractEntityPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 446, Short.MAX_VALUE)
        );
        abstractEntityPanelLayout.setVerticalGroup(
            abstractEntityPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 331, Short.MAX_VALUE)
        );

        contentPanel.add(abstractEntityPanel, java.awt.BorderLayout.CENTER);

        getContentPane().add(contentPanel, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private org.opu.db.obj.vis.ui.client.widgets.AbstractEntityPanel abstractEntityPanel;
    private javax.swing.JPanel attributePanel;
    private javax.swing.JButton cancelBtn;
    private javax.swing.JPanel contentPanel;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JButton okBtn;
    // End of variables declaration//GEN-END:variables

}
